//mutations
export default {
    addCart(state,goods) {
        let hasList = state.cartList.find(v=>v.gid===goods.gid);
        if(hasList){
            hasList.goods_num++
        }else {
            state.cartList.unshift({
                gid:goods.gid,
                photo:goods.photo,
                subject:goods.subject,
                sale_price:goods.sale_price,
                goods_num:1,
                checked:true,
                allChecked:true
            });
        }
    },
    changeGoodsNum(state,{ id, number }) {
        state.cartList.find(v=>v.gid===id).goods_num = number;
    }
}